#ifndef DIAGCONFIG_H__
#define DIAGCONFIG_H__

#include <cstdint>
#include <string>

struct DiagConfig
{
    DiagConfig() = default;
    ~DiagConfig() = default;

    /**
     * 从usersettings.ini配置文件中读取配置信息
     */
    int32_t Init(const std::string& usersettings);

    uint32_t BaseDur() const { return baseDur; }

    uint32_t MaxDur() const { return maxDur; }

    uint32_t StepDur() const { return stepDur; }

    uint32_t MaxDiagByte() const { return maxFileBytes; }

    uint32_t AdvanceTimePercentage() const { return advanceTimePercentage % 101; }

    const static std::string DIAG_BASE_DUR_KEY;
    const static std::string DIAG_MAX_DUR_KEY;
    const static std::string DIAG_STEP_KEY;
    const static std::string DIAG_MAX_FILE_BYTES_KEY;

    /* 基础日志记录时长: 默认60s */
    constexpr static uint32_t DEF_DIAG_BASE_DUR = 60;
    /* 最大诊断记录时长: 默认180s */
    constexpr static uint32_t DEF_DIAG_MAX_DUR = 180;
    /* 诊断记录时间步长: 默认30s */
    constexpr static uint32_t DEF_DIAG_STEP_DUR = 30;
    /* 最大诊断磁盘占用限制: 1024M */
    constexpr static uint32_t DEF_DIAG_MAX_FILE_BYTES = 0x40000000u;
    /* 默认自动诊断CAN报文记录时间提前量占基础日志记录时长百分比，0 ~ 100% */
    constexpr static uint32_t DEF_DIAG_ADVANCE_TIME_PERCENTAGE = 50;

    uint32_t baseDur = DEF_DIAG_BASE_DUR;
    uint32_t maxDur = DEF_DIAG_MAX_DUR;
    uint32_t stepDur = DEF_DIAG_STEP_DUR;
    uint32_t maxFileBytes = DEF_DIAG_MAX_FILE_BYTES;
    uint32_t advanceTimePercentage = DEF_DIAG_ADVANCE_TIME_PERCENTAGE;
};

#endif  // DIAGCONFIG_H__